package com.app.micaihu.custom.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.app.micaihu.R;
import com.app.micaihu.bean.news.VideoChannel;
import com.app.utils.util.image.LoadImageUtils;

/**
 * 视频栏目icon的自定义控件
 * Created by linkai on 2016/9/7.
 */
public class VideoChannelView extends LinearLayout {


    public VideoChannelView(Context context) {
        super(context);
        inflate(context,R.layout.view_videochanel, this);
    }

    public VideoChannelView(Context context, AttributeSet attrs) {
        super(context, attrs);
        inflate(context, R.layout.view_videochanel, this);
    }

    /**
     * 初始化数据
     * @param videoChannel
     */
    public void setData(VideoChannel videoChannel){
        if(videoChannel == null){
            setVisibility(View.VISIBLE);
            return;
        }
        CustomImageView img = (CustomImageView) findViewById(android.R.id.icon);
        if(img != null){
            LoadImageUtils.getInstance().loadImage(img,videoChannel.getIcon());
        }
        TextView title = (TextView) findViewById(android.R.id.text1);
        title.setText(videoChannel.getTitle());
        setTag(videoChannel);
    }
}
